<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   如何用R实现空间数据可视化  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/878.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466455235: Accept with keywords: (title(0.25):空间数据,社区,可视化,数盟, topn(0.166666666667):市辖区,数盟,崇明县,地理,地名,文件,边界,长沙,区域,可视化,文章,格式,数据,多边形,函数,望城县,长沙县,流行病学,空间数据,运算符,绘制地图,绘制,代码,地图,长沙市,字段,官方,绘图,软件,上海市).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    如何用R实现空间数据可视化
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    如何用R实现空间数据可视化 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,60] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/devl">
       编程语言
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/878.html">
          如何用R实现空间数据可视化
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          2,442 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/devl" rel="category tag">
          编程语言
         </a>
         ,
         <a href="http://dataunion.org/category/tech/viz" rel="category tag">
          可视化
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <blockquote style="font-style: italic; color: #141412;">
        <p>
         本文作者：姜晓东，博士毕业于上海交通大学，目前任教于湖南师范大学医学院，专业神经毒理学。
        </p>
       </blockquote>
       <div class="a3s" style="color: #141412;">
        流行病学的数据讲究“三间分布”，即人群分布、时间分布和空间分布。其中的“空间分布”最好是在地图上展示，才比较清楚。R软件集统计分析与高级绘图于大成，是最适合做这项工作了。关于地图的绘制过程，谢益辉、邱怡轩和陈丽云等人都早有文章讲述，开R地图中文教程之先河。由于目前指导毕业论文用到，因此研究了一下。本来因为网上教程很多，曾打消了写些文字的计划，但怡轩版主鼓励说“教程者众，整合者鲜”，所以才战胜拖延症，提起拙笔综述整合一下，并对DIY统计GIS地图提出了一点自己的想法。
       </div>
       <h3 style="color: #141412;">
        1 地图GIS数据的来源与R绘制软件包
       </h3>
       <p style="color: #141412;">
        中国地图GIS数据的官方数据可以在国家基础地理信息中心的网站（
        <a href="http://nfgis.nsdi.gov.cn/" style="color: #bc360a;" target="_blank">
         http://nfgis.nsdi.gov.cn
        </a>
        ）里面可以免费下载。官方公开的数据包括：地图数据，及居住地、交通、河流等辅助数据。今年6月开始，官方正组织开始制作新版数据。老数据暂时无法下载，读者要自行百度搜索，本文以旧版数据为例。旧版地图数据中部分地名和地市区划已经过时，使用时需注意。
       </p>
       <p style="color: #141412;">
        地图数据有4个压缩文件：bou1_4m.zip、bou2_4m.zip、bou3_4m.zip和bou4_4m.zip。bou代表边界的意思，数字1~4代表国家、省、市、县的4级行政划分；4m代表比例是400万分之一，这个比例的图形是公开的。每个文件解压缩后含有两类文件：以字母p结尾的表示多边形数据，用来绘制区域；以字母l结尾的文件是线形数据，用来绘制边界。但是老版数据中，市级数据中缺少绘制区域的多边形数据，让市级分布图的绘制稍麻烦一些，新版中也许会有改进。
       </p>
       <p style="color: #141412;">
        用R绘制地图比较简单。比如画一下全国范围的区域，可以用如下代码：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e6f5452796496" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          library(maptools)
mydat = readShapePoly("maps/bou1/bou1_4p.shp")
plot(mydat)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e6f5452796496-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e6f5452796496-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e6f5452796496-3">
               3
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e6f5452796496-1">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                maptools
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e6f5452796496-2">
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                readShapePoly
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "maps/bou1/bou1_4p.shp"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e6f5452796496-3">
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0010 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://cos.name/wp-content/uploads/2014/08/unnamed-chunk-1.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-1-e1408027878462.png"/>
        </a>
        <br/>
        但是，可以看出这样绘制的地图的形状有些扁平。这是因为，在绘图的过程中，默认把经度和纬度作为普通数据，均匀平等对待，绘制在笛卡尔坐标系上造成的。其实，地球的球面图形如何映射到平面图上，在地理学上是有一系列不同的专业算法的。地图不应该画在普通的笛卡尔坐标系上，而是要画在地理学专业的坐标系上。在这一点上，R的ggplot2包提供了专门的
        <code>
         coord_map()
        </code>
        函数。所以推荐R的ggplot2包来绘制地图。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e70b282005685" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          library(ggplot2)
mymap = ggplot(data = fortify(mydat)) +
    geom_polygon(aes(x = long, y = lat, group = id), colour = "black",
                 fill = NA) +
    theme_grey()
print(mymap + coord_map())
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e70b282005685-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e70b282005685-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e70b282005685-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e70b282005685-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e70b282005685-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e70b282005685-6">
               6
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e70b282005685-1">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                ggplot2
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e70b282005685-2">
               <span class="crayon-v">
                mymap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                ggplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                fortify
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e70b282005685-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                geom_polygon
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                aes
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                long
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                lat
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                group
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                colour
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "black"
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e70b282005685-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fill
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                NA
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e70b282005685-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                theme_grey
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e70b282005685-6">
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mymap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coord_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0149 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-2.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-2.png"/>
        </a>
        <br/>
        这次中国地图的形状与百度地图一样了。
        <span id="more-10181">
        </span>
       </p>
       <p style="color: #141412;">
        ggplot2包的
        <code>
         coord_map
        </code>
        函数默认的映射类型是mercator。如果有其他需要，可以使用其他的映射类型来绘制地图，如：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e713789966016" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          mymap + coord_map(projection = "azequidistant")
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e713789966016-1">
               1
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e713789966016-1">
               <span class="crayon-v">
                mymap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coord_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                projection
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "azequidistant"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0099 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://cos.name/wp-content/uploads/2014/08/unnamed-chunk-3.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-3-e1408027824797.png"/>
        </a>
        <code>
         coord_map
        </code>
        函数的映射类型及其含义可以通过下列代码查询帮助，一般我们用默认的就可以。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e719610221280" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          library(mapproj)
?mapproject
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e719610221280-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e719610221280-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e719610221280-1">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mapproj
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e719610221280-2">
               <span class="crayon-sy">
                ?
               </span>
               <span class="crayon-v">
                mapproject
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0007 seconds] -->
       <p>
       </p>
       <h3 style="color: #141412;">
        2 GIS地图的数据结构及省市地图的绘制
       </h3>
       <p style="color: #141412;">
        GIS地图有很多种存储格式，其中shapefile格式（.shp）可以通过R的maptools包打开。其他格式可以去R官网查询相应的软件包。
       </p>
       <p style="color: #141412;">
        地图数据基本可以分为点、线、面三种数据，在maptools包内分别有对应的函数来读取（
        <code>
         readShapePoints
        </code>
        、
        <code>
         readShapeLines
        </code>
        和
        <code>
         readShapePoly
        </code>
        函数）。首先以面（poly）型数据介绍。先看代码，通过
        <code>
         readShapePoly
        </code>
        函数读入省级地图：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e720598960568" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          library(maptools)
mydat = readShapePoly("maps/bou2/bou2_4p.shp")
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e720598960568-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e720598960568-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e720598960568-1">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                maptools
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e720598960568-2">
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                readShapePoly
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "maps/bou2/bou2_4p.shp"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0062 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        此时，
        <code>
         mydat
        </code>
        中保存的是各个省/直辖市的多边形面图，数据类型是
        <code>
         SpatialPolygonsDataFrame
        </code>
        。我们可以：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e726348871783" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          length(mydat)

## [1] 925

names(mydat)

## [1] "AREA" "PERIMETER" "BOU2_4M_" "BOU2_4M_ID" "ADCODE93"
## [6] "ADCODE99" "NAME"
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e726348871783-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e726348871783-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e726348871783-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e726348871783-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e726348871783-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e726348871783-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e726348871783-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e726348871783-8">
               8
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e726348871783-1">
               <span class="crayon-e">
                length
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e726348871783-2">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e726348871783-3">
               <span class="crayon-p">
                ## [1] 925
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e726348871783-4">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e726348871783-5">
               <span class="crayon-e">
                names
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e726348871783-6">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e726348871783-7">
               <span class="crayon-p">
                ## [1] "AREA" "PERIMETER" "BOU2_4M_" "BOU2_4M_ID" "ADCODE93"
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e726348871783-8">
               <span class="crayon-p">
                ## [6] "ADCODE99" "NAME"
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0011 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        可以发现
        <code>
         mydat
        </code>
        中有925条记录，每条记录中含有面积（AREA）、周长（PERIMETER）、各种编号、中文名（NAME）等字段。其中中文名（NAME）字段是以GBK编码的。
       </p>
       <p style="color: #141412;">
        这个
        <code>
         SpatialPolygonsDataFrame
        </code>
        类型并不是真正的
        <code>
         data.frame
        </code>
        类型，而是一个sp包定义的类，只不过重载了
        <code>
         []
        </code>
        和
        <code>
         $
        </code>
        运算符，使得一些行为上与
        <code>
         data.frame
        </code>
        相类似。
       </p>
       <p style="color: #141412;">
        可以进一步统计一下，每个省/直辖市的多边形数目。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e730653441989" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          table(iconv(mydat$NAME, from = "GBK"))

## 
##           上海市           云南省     内蒙古自治区           北京市 
##               12                1                1                1 
##           台湾省           吉林省           四川省           天津市 
##               57                1                1                1 
##   宁夏回族自治区           安徽省           山东省           山西省 
##                1                1               86                1 
##           广东省   广西壮族自治区 新疆维吾尔自治区           江苏省 
##              154                6                1                5 
##           江西省           河北省           河南省           浙江省 
##                1                9                1              179 
##           海南省           湖北省           湖南省           甘肃省 
##               79                1                1                1 
##           福建省       西藏自治区           贵州省           辽宁省 
##              168                1                2               94 
##           重庆市           陕西省           青海省   香港特别行政区 
##                1                1                1               53 
##         黑龙江省 
##                1
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e730653441989-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e730653441989-21">
               21
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e730653441989-1">
               <span class="crayon-e">
                table
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                NAME
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "GBK"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-2">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-3">
               <span class="crayon-p">
                ##
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-4">
               <span class="crayon-p">
                ##           上海市           云南省     内蒙古自治区           北京市
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-5">
               <span class="crayon-p">
                ##               12                1                1                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-6">
               <span class="crayon-p">
                ##           台湾省           吉林省           四川省           天津市
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-7">
               <span class="crayon-p">
                ##               57                1                1                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-8">
               <span class="crayon-p">
                ##   宁夏回族自治区           安徽省           山东省           山西省
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-9">
               <span class="crayon-p">
                ##                1                1               86                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-10">
               <span class="crayon-p">
                ##           广东省   广西壮族自治区 新疆维吾尔自治区           江苏省
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-11">
               <span class="crayon-p">
                ##              154                6                1                5
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-12">
               <span class="crayon-p">
                ##           江西省           河北省           河南省           浙江省
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-13">
               <span class="crayon-p">
                ##                1                9                1              179
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-14">
               <span class="crayon-p">
                ##           海南省           湖北省           湖南省           甘肃省
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-15">
               <span class="crayon-p">
                ##               79                1                1                1
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-16">
               <span class="crayon-p">
                ##           福建省       西藏自治区           贵州省           辽宁省
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-17">
               <span class="crayon-p">
                ##              168                1                2               94
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-18">
               <span class="crayon-p">
                ##           重庆市           陕西省           青海省   香港特别行政区
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-19">
               <span class="crayon-p">
                ##                1                1                1               53
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e730653441989-20">
               <span class="crayon-p">
                ##         黑龙江省
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e730653441989-21">
               <span class="crayon-p">
                ##                1
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0185 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        我的环境是UTF-8，所以需要
        <code>
         iconv
        </code>
        函数转化一下才能正常显示。
       </p>
       <p style="color: #141412;">
        结果显示多数省的地图都是由一个多边形构成，少数临海省/直辖市由于有很多附属岛屿，多边形数目比较多。
       </p>
       <p style="color: #141412;">
        利用与
        <code>
         data.frame
        </code>
        相似的
        <code>
         []
        </code>
        和
        <code>
         $
        </code>
        运算符操作，我们可以迅速提取出一个省市的数据，比如上海及附属崇明岛：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e738425375751" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Shanghai = mydat[mydat$ADCODE99 == 310000,]
plot(Shanghai)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e738425375751-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e738425375751-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e738425375751-1">
               <span class="crayon-v">
                Shanghai
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                ADCODE99
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                310000
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e738425375751-2">
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                Shanghai
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0011 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://cos.name/wp-content/uploads/2014/08/unnamed-chunk-8.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-8-e1408027792888.png"/>
        </a>
       </p>
       <p style="color: #141412;">
        其中ADCODE99是国家基础地理信息中心定义的区域代码，共有6位数字，由省、地市、县各两位代码组成。
       </p>
       <p style="color: #141412;">
        为了进一步在ggplot2包中绘图，需要把
        <code>
         SpatialPolygonsDataFrame
        </code>
        数据类型转化为真正的
        <code>
         data.frame
        </code>
        类型才可以。ggplot2包专门针对地理数据提供了特化版本的
        <code>
         fortify
        </code>
        函数来做这个工作：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e73e432342031" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          head(fortify(Shanghai))

##    long   lat order  hole piece group  id
## 1 121.3 31.85     1 FALSE     1 208.1 208
## 2 121.3 31.85     2 FALSE     1 208.1 208
## 3 121.3 31.85     3 FALSE     1 208.1 208
## 4 121.3 31.85     4 FALSE     1 208.1 208
## 5 121.3 31.84     5 FALSE     1 208.1 208
## 6 121.4 31.83     6 FALSE     1 208.1 208
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e73e432342031-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e73e432342031-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e73e432342031-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e73e432342031-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e73e432342031-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e73e432342031-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e73e432342031-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e73e432342031-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e73e432342031-9">
               9
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e73e432342031-1">
               <span class="crayon-e">
                head
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                fortify
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                Shanghai
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e73e432342031-2">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e73e432342031-3">
               <span class="crayon-p">
                ##    long   lat order  hole piece group  id
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e73e432342031-4">
               <span class="crayon-p">
                ## 1 121.3 31.85     1 FALSE     1 208.1 208
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e73e432342031-5">
               <span class="crayon-p">
                ## 2 121.3 31.85     2 FALSE     1 208.1 208
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e73e432342031-6">
               <span class="crayon-p">
                ## 3 121.3 31.85     3 FALSE     1 208.1 208
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e73e432342031-7">
               <span class="crayon-p">
                ## 4 121.3 31.85     4 FALSE     1 208.1 208
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e73e432342031-8">
               <span class="crayon-p">
                ## 5 121.3 31.84     5 FALSE     1 208.1 208
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e73e432342031-9">
               <span class="crayon-p">
                ## 6 121.4 31.83     6 FALSE     1 208.1 208
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0229 seconds] -->
       <p>
       </p>
       <h3 style="color: #141412;">
        3 在地图上展示流行病学数据
       </h3>
       <h4 style="color: #141412;">
        3.1 一地名对应一区域，长沙为例
       </h4>
       <p style="color: #141412;">
        首先把长沙所辖地区找到，这个可以根据ADCODE99编码的前4位定位长沙，去查表就可以了。但是这个地名是99年的标准，新版正在制定过程中，随时会变。我们权且以此为例。如果找不到表，可以通过代码在命令行下手工查找：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e745058960693" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          mydat = readShapePoly("maps/bou4/BOUNT_poly.shp")
tmp = iconv(mydat$NAME99, from = "GBK")
grep("长沙", tmp, value = TRUE)

## [1] "长沙县"       "长沙市市辖区"

grep("长沙", tmp)

## [1] 2122 2183

mydat$ADCODE99[grep("长沙", tmp)]

## [1] 430121 430101
## 2368 Levels: 0 110100 110112 110113 110221 110224 110226 110227 ... 820000
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e745058960693-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e745058960693-14">
               14
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e745058960693-1">
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                readShapePoly
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "maps/bou4/BOUNT_poly.shp"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-2">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                NAME99
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "GBK"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e745058960693-3">
               <span class="crayon-e">
                grep
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "长沙"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                value
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                TRUE
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-4">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e745058960693-5">
               <span class="crayon-p">
                ## [1] "长沙县"       "长沙市市辖区"
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-6">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e745058960693-7">
               <span class="crayon-e">
                grep
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "长沙"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-8">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e745058960693-9">
               <span class="crayon-p">
                ## [1] 2122 2183
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-10">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e745058960693-11">
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                ADCODE99
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-e">
                grep
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "长沙"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-12">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e745058960693-13">
               <span class="crayon-p">
                ## [1] 430121 430101
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e745058960693-14">
               <span class="crayon-p">
                ## 2368 Levels: 0 110100 110112 110113 110221 110224 110226 110227 ... 820000
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0120 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        这样我们就知道了长沙ADCODE99编码的前4位是4301，其中43代表湖南省，01就是长沙市。接着就可以筛选出长沙的地图数据：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e74e086314850" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Changsha = mydat[substr(as.character(mydat$ADCODE99), 1, 4) == "4301",]
mysh = fortify(Changsha, region = 'NAME99')
mysh = transform(mysh, id = iconv(id, from = 'GBK'), group = iconv(group, from = 'GBK'))
head(mysh, n = 2)

##    long   lat order  hole piece          group           id
## 1 113.1 28.18     1 FALSE     1 长沙市市辖区.1 长沙市市辖区
## 2 113.1 28.18     2 FALSE     1 长沙市市辖区.1 长沙市市辖区

names(mysh)[1:2] = c("x","y")   #这句是不得已而为之的黑魔法
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e74e086314850-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e74e086314850-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e74e086314850-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e74e086314850-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e74e086314850-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e74e086314850-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e74e086314850-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e74e086314850-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e74e086314850-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e74e086314850-10">
               10
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e74e086314850-1">
               <span class="crayon-v">
                Changsha
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-e">
                substr
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                character
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                ADCODE99
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                4
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "4301"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e74e086314850-2">
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                fortify
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                Changsha
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                region
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'NAME99'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e74e086314850-3">
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                transform
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'GBK'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                group
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                group
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'GBK'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e74e086314850-4">
               <span class="crayon-e">
                head
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                n
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e74e086314850-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e74e086314850-6">
               <span class="crayon-p">
                ##    long   lat order  hole piece          group           id
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e74e086314850-7">
               <span class="crayon-p">
                ## 1 113.1 28.18     1 FALSE     1 长沙市市辖区.1 长沙市市辖区
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e74e086314850-8">
               <span class="crayon-p">
                ## 2 113.1 28.18     2 FALSE     1 长沙市市辖区.1 长沙市市辖区
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e74e086314850-9">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e74e086314850-10">
               <span class="crayon-e">
                names
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "x"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-s">
                "y"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-p">
                #这句是不得已而为之的黑魔法
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0188 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        接着我们给一串随机数当成是流行病学数据，并用颜色填充到地图上。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e755504759286" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          myepidat = data.frame(id = unique(sort(mysh$id)))
myepidat$rand = runif(length(myepidat$id))
myepidat

##             id    rand
## 1       宁乡县 0.98076
## 2       望城县 0.32123
## 3       浏阳市 0.66957
## 4       长沙县 0.09655
## 5 长沙市市辖区 0.19437

csmap = ggplot(myepidat) +
    geom_map(aes(map_id = id, fill = rand), color = "white", map = mysh) +
    scale_fill_gradient(high = "darkgreen",low = "lightgreen") +
    expand_limits(mysh) + coord_map()
print(csmap)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e755504759286-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e755504759286-16">
               16
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e755504759286-1">
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                unique
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                sort
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-2">
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                rand
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                runif
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                length
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-3">
               <span class="crayon-v">
                myepidat
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-4">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-5">
               <span class="crayon-p">
                ##             id    rand
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-6">
               <span class="crayon-p">
                ## 1       宁乡县 0.98076
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-7">
               <span class="crayon-p">
                ## 2       望城县 0.32123
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-8">
               <span class="crayon-p">
                ## 3       浏阳市 0.66957
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-9">
               <span class="crayon-p">
                ## 4       长沙县 0.09655
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-10">
               <span class="crayon-p">
                ## 5 长沙市市辖区 0.19437
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-11">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-12">
               <span class="crayon-v">
                csmap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                ggplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                geom_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                aes
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                map_id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fill
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                rand
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "white"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                map
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                scale_fill_gradient
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                high
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "darkgreen"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                low
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "lightgreen"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e755504759286-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                expand_limits
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coord_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e755504759286-16">
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                csmap
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0109 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://cos.name/wp-content/uploads/2014/08/unnamed-chunk-12.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-12-e1408027716212.png"/>
        </a>
        接下来的工作就是添加地名，sp包提供了
        <code>
         coordinates
        </code>
        函数，来计算地图的中心坐标：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e75c276125978" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          tmp = coordinates(Changsha)
print(tmp)

##       [,1]  [,2]
## 2121 113.2 28.32
## 2134 113.7 28.23
## 2136 112.8 28.29
## 2149 112.3 28.13
## 2182 113.0 28.17

tmp = as.data.frame(tmp)
tmp$names = iconv(Changsha$NAME99, from = 'GBK')
print(tmp)

##         V1    V2        names
## 2121 113.2 28.32       长沙县
## 2134 113.7 28.23       浏阳市
## 2136 112.8 28.29       望城县
## 2149 112.3 28.13       宁乡县
## 2182 113.0 28.17 长沙市市辖区

csmap + geom_text(aes(x = V1,y = V2,label = names), family = "GB1", data = tmp)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e75c276125978-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e75c276125978-22">
               22
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-1">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coordinates
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                Changsha
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-2">
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-3">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-4">
               <span class="crayon-p">
                ##       [,1]  [,2]
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-5">
               <span class="crayon-p">
                ## 2121 113.2 28.32
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-6">
               <span class="crayon-p">
                ## 2134 113.7 28.23
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-7">
               <span class="crayon-p">
                ## 2136 112.8 28.29
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-8">
               <span class="crayon-p">
                ## 2149 112.3 28.13
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-9">
               <span class="crayon-p">
                ## 2182 113.0 28.17
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-10">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-11">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-12">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                names
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                Changsha
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                NAME99
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'GBK'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-13">
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-14">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-15">
               <span class="crayon-p">
                ##         V1    V2        names
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-16">
               <span class="crayon-p">
                ## 2121 113.2 28.32       长沙县
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-17">
               <span class="crayon-p">
                ## 2134 113.7 28.23       浏阳市
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-18">
               <span class="crayon-p">
                ## 2136 112.8 28.29       望城县
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-19">
               <span class="crayon-p">
                ## 2149 112.3 28.13       宁乡县
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-20">
               <span class="crayon-p">
                ## 2182 113.0 28.17 长沙市市辖区
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e75c276125978-21">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e75c276125978-22">
               <span class="crayon-v">
                csmap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                geom_text
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                aes
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                V1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                V2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                names
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                family
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "GB1"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0065 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://cos.name/wp-content/uploads/2014/08/unnamed-chunk-13.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-13-e1408027752719.png"/>
        </a>
        如果需要支持更多字体，可以配合使用showtext包。
       </p>
       <h4 style="color: #141412;">
        3.2 内地省份的地市级图的情况
       </h4>
       <p style="color: #141412;">
        如果国家基础地理信息中心的GIS地图数据的地市文件bou3_4m.zip中含有polygon文件，那么我们就可以根据上一节的内容绘制省内地市级分布图了。官方恰恰缺少了这个文件，给绘图造成了麻烦。解决方案有两个：一个是另辟蹊径，从非官方的
        <a href="http://www.gadm.org/" style="color: #bc360a;">
         www.gadm.org
        </a>
        下载一份shp格式的中国地图来绘制；另一个解决方案是从官方发布的县级地图入手，根据ADCODE99编码适当合并，绘制省内地市分布图，同时利用bou3_4m.zip仅存的边界文件绘制边界。
       </p>
       <p style="color: #141412;">
        相信官方新版本的GIS地图数据会包含旧版本所缺失的这份文件。目前还是建议暂时使用gadm的省级地图。旧版官方地图信息比较陈旧落后，比如湖南没有标注出湘西州的规划。
       </p>
       <h4 style="color: #141412;">
        3.3 一地名对应多区域，上海为例
       </h4>
       <p style="color: #141412;">
        中国很多沿海省/直辖市有很多附属岛屿，导致地名和区域（Polygon）存在一对多的情况。这种情况下，在
        <code>
         fortify
        </code>
        处理数据的时候一定要特别注意索引与多边形一一对应，同时又要保持地名信息，黑魔法在代码中：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e763032322195" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          # mydat = readShapePoly("maps/bou4/BOUNT_poly.shp")
Shanghai = mydat[substr(as.character(mydat$ADCODE99), 1, 2) == '31',]
mysh = fortify(Shanghai, region = 'NAME99')
mysh = transform(mysh, id = iconv(id, from = 'GBK'), group = iconv(group, from = 'GBK'))
head(mysh)

##    long   lat order  hole piece    group     id
## 1 121.2 31.85     1 FALSE     1 崇明县.1 崇明县
## 2 121.3 31.85     2 FALSE     1 崇明县.1 崇明县
## 3 121.3 31.85     3 FALSE     1 崇明县.1 崇明县
## 4 121.3 31.85     4 FALSE     1 崇明县.1 崇明县
## 5 121.3 31.85     5 FALSE     1 崇明县.1 崇明县
## 6 121.3 31.84     6 FALSE     1 崇明县.1 崇明县

# 黑魔法在此
names(mysh)[c(1, 2, 6, 7)] = c("x", "y", "id", "code")

myepidat = data.frame(id = unique(sort(mysh$id)))
# 随机数字替代数据
myepidat$rand = runif(length(myepidat$id))

# 官方地图区划比较落后过时，目前上海是16区1县，神码“市直辖5区”的称呼已经过时。
myepidat

##                id    rand
## 1  上海市市辖区.1 0.21673
## 2  上海市市辖区.2 0.74173
## 3  上海市市辖区.3 0.02462
## 4  上海市市辖区.4 0.20619
## 5  上海市市辖区.5 0.89970
## 6        南汇县.1 0.77084
## 7        嘉定区.1 0.21771
## 8        奉贤县.1 0.91729
## 9        崇明县.1 0.04879
## 10       崇明县.2 0.02462
## 11       崇明县.3 0.03397
## 12       崇明县.4 0.72591
## 13       崇明县.5 0.72059
## 14       崇明县.6 0.43981
## 15       松江区.1 0.18296
## 16       金山区.1 0.78371
## 17       金山区.2 0.88552
## 18       闵行区.1 0.54186
## 19       青浦县.1 0.12003

ggplot(myepidat) + geom_map(aes(map_id = id, fill = rand), map = mysh) +
    expand_limits(mysh) + coord_map()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-37">
               37
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-38">
               38
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-39">
               39
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-40">
               40
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-41">
               41
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-42">
               42
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-43">
               43
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-44">
               44
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-45">
               45
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e763032322195-46">
               46
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e763032322195-47">
               47
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e763032322195-1">
               <span class="crayon-p">
                # mydat = readShapePoly("maps/bou4/BOUNT_poly.shp")
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-2">
               <span class="crayon-v">
                Shanghai
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-e">
                substr
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                character
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                ADCODE99
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ==
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '31'
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-sy">
                ]
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-3">
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                fortify
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                Shanghai
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                region
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'NAME99'
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-4">
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                transform
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'GBK'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                group
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                iconv
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                group
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                from
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'GBK'
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-5">
               <span class="crayon-e">
                head
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-6">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-7">
               <span class="crayon-p">
                ##    long   lat order  hole piece    group     id
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-8">
               <span class="crayon-p">
                ## 1 121.2 31.85     1 FALSE     1 崇明县.1 崇明县
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-9">
               <span class="crayon-p">
                ## 2 121.3 31.85     2 FALSE     1 崇明县.1 崇明县
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-10">
               <span class="crayon-p">
                ## 3 121.3 31.85     3 FALSE     1 崇明县.1 崇明县
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-11">
               <span class="crayon-p">
                ## 4 121.3 31.85     4 FALSE     1 崇明县.1 崇明县
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-12">
               <span class="crayon-p">
                ## 5 121.3 31.85     5 FALSE     1 崇明县.1 崇明县
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-13">
               <span class="crayon-p">
                ## 6 121.3 31.84     6 FALSE     1 崇明县.1 崇明县
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-14">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-15">
               <span class="crayon-p">
                # 黑魔法在此
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-16">
               <span class="crayon-e">
                names
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                6
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                7
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "x"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "y"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "id"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "code"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-17">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-18">
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                unique
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                sort
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-19">
               <span class="crayon-p">
                # 随机数字替代数据
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-20">
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                rand
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                runif
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                length
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-21">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-22">
               <span class="crayon-p">
                # 官方地图区划比较落后过时，目前上海是16区1县，神码“市直辖5区”的称呼已经过时。
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-23">
               <span class="crayon-v">
                myepidat
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-24">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-25">
               <span class="crayon-p">
                ##                id    rand
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-26">
               <span class="crayon-p">
                ## 1  上海市市辖区.1 0.21673
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-27">
               <span class="crayon-p">
                ## 2  上海市市辖区.2 0.74173
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-28">
               <span class="crayon-p">
                ## 3  上海市市辖区.3 0.02462
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-29">
               <span class="crayon-p">
                ## 4  上海市市辖区.4 0.20619
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-30">
               <span class="crayon-p">
                ## 5  上海市市辖区.5 0.89970
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-31">
               <span class="crayon-p">
                ## 6        南汇县.1 0.77084
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-32">
               <span class="crayon-p">
                ## 7        嘉定区.1 0.21771
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-33">
               <span class="crayon-p">
                ## 8        奉贤县.1 0.91729
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-34">
               <span class="crayon-p">
                ## 9        崇明县.1 0.04879
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-35">
               <span class="crayon-p">
                ## 10       崇明县.2 0.02462
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-36">
               <span class="crayon-p">
                ## 11       崇明县.3 0.03397
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-37">
               <span class="crayon-p">
                ## 12       崇明县.4 0.72591
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-38">
               <span class="crayon-p">
                ## 13       崇明县.5 0.72059
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-39">
               <span class="crayon-p">
                ## 14       崇明县.6 0.43981
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-40">
               <span class="crayon-p">
                ## 15       松江区.1 0.18296
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-41">
               <span class="crayon-p">
                ## 16       金山区.1 0.78371
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-42">
               <span class="crayon-p">
                ## 17       金山区.2 0.88552
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-43">
               <span class="crayon-p">
                ## 18       闵行区.1 0.54186
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-44">
               <span class="crayon-p">
                ## 19       青浦县.1 0.12003
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-45">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e763032322195-46">
               <span class="crayon-e">
                ggplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                geom_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                aes
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                map_id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fill
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                rand
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                map
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e763032322195-47">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                expand_limits
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coord_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0150 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-14.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-14.png"/>
        </a>
       </p>
       <h4 style="color: #141412;">
        3.4 其他问题
       </h4>
       <p style="color: #141412;">
        如果需要县级以下的地图GIS数据，比如街道、乡村的地图，国家地理信息中心并不提供。要么去民政部索取，要么自己绘制。
       </p>
       <p style="color: #141412;">
        另外，提醒大家，流行病学数据并不是仅仅画在地图上就完事了。针对空间数据，R里面有很多空间数据的分析软件包。推荐Roger S. Bivand的《Applied Spatial Data Analysis with R》，尤其是里面第11章“Disease Mapping”，对医学背景同学很有益处。如果能找到一个地理资源环境学院的研究生一同讨论的话就更好了。毕竟，它山之石可以攻玉，我们要承认自己的不足。
       </p>
       <h3 style="color: #141412;">
        4 自己绘制简单的GIS地图
       </h3>
       <p style="color: #141412;">
        在制作流行病学统计地图的过程中，对于很多区、街道、乡村级别的地图，无法获得GIS数据。很多人的做法是到百度地图上用绘图软件摹描出区域线图，然后再把自己的数据计算成相应颜色，再手工填充颜色绘成统计地图。这个过程枯燥繁琐，而且数据映射成颜色的时候容易出错。不如把你已经描好的线图，制成shp格式的GIS数据地图，分享给大家用。辛苦你一个，幸福千万家。这个过程其实有专业的GIS软件可以做，若你能找到专业人士，就直接“幸福千万家”了。
       </p>
       <p style="color: #141412;">
        如果地图结构简单，我们可以“土法”来做。先去NIH（美国国立卫生研究院）网站下载一个免费的图像软件ImageJ，用来采集地区边界数据。然后再把采集好的数据在R软件里面把像素坐标换算成地理坐标，在利用R软件sp包和maptools的函数整合成
        <code>
         SpatialPolygonsDataFrame
        </code>
        ，最后保存为shp格式的地图文件。
       </p>
       <p style="color: #141412;">
        我们以起点中文网小说《江山美人志》开篇所附地图为例，绘制虚拟世界里面“中南郡”的GIS地图。为了和实际问题类似，我在地图中画上了参考坐标线。
       </p>
       <p style="color: #141412;">
        <a href="http://dataunion.org/wp-content/uploads/2015/01/mymap.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/mymap.png"/>
        </a>
       </p>
       <p style="color: #141412;">
        利用ImageJ“点”工具，同时按住Shift键一次批量多点采样，再点击分析菜的测量，最后保存结果。
       </p>
       <p style="color: #141412;">
        ImageJ采集的点坐标是位图像素相对坐标，为了能换算为地理经纬度坐标。我们先采集图上参考坐标线上的经纬交点坐标，在R中建立换算关系：
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e771147483846" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          mg_pos = data.frame(x = c(103,103,403,403), y = c(75,275,75,275))
real_pos = data.frame(x = c(105,105,115,115), y = c(27,20,27,20))

data_x = data.frame(img = img_pos$x, rel = real_pos$x)
data_y = data.frame(img = img_pos$y, rel = real_pos$y)

lm_x = lm(rel~img, data = data_x)
lm_y = lm(rel~img, data = data_y)

mytrans_x = function(myimg) {
     predict(lm_x, newdata = data.frame(img = myimg))
}
mytrans_y = function(myimg) {
     predict(lm_y, newdata = data.frame(img = myimg))
}
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e771147483846-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e771147483846-15">
               15
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e771147483846-1">
               <span class="crayon-v">
                mg_pos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                103
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                103
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                403
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                403
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                75
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                275
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                75
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                275
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-2">
               <span class="crayon-v">
                real_pos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                105
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                105
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                115
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                115
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-cn">
                27
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                20
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                27
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-cn">
                20
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-3">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-4">
               <span class="crayon-v">
                data_x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                img_pos
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                rel
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                real_pos
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-5">
               <span class="crayon-v">
                data_y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                img_pos
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                rel
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                real_pos
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-6">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-7">
               <span class="crayon-v">
                lm_x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                lm
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                rel
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data_x
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-8">
               <span class="crayon-v">
                lm_y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                lm
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                rel
               </span>
               <span class="crayon-o">
                ~
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data_y
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-9">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-10">
               <span class="crayon-v">
                mytrans_x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                function
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myimg
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                predict
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                lm_x
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                newdata
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                myimg
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-12">
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-13">
               <span class="crayon-v">
                mytrans_y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                function
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myimg
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e771147483846-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                predict
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                lm_y
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                newdata
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                img
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                myimg
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e771147483846-15">
               <span class="crayon-sy">
                }
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0141 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        然后，再利用ImageJ软件对中南郡的每个区域轮廓线单独描边采样，这样做的缺点就是两个区域相邻边会有些不一致，出现小幅的咬合错位现象，但这个对美观影响不大。优点是大大节省时间。
       </p>
       <p style="color: #141412;">
        把每个区域的边界保存在单独的文件中。然后在R中把这些数据转化为GIS数据，保存为shp格式的标准地图文件。关于代码中函数的意义及范例（比我的代码更清晰），请参考sp和maptools包的帮助文件。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e77e403796929" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          library(maptools)

myfiles = c("Jiana.xls", "Kutedan.xls", "Miyaluo.xls", "Woda.xls", "Yada.xls")
mypolys = lapply(myfiles,
                 function(x) {
                     tmp = read.table(paste0("data/", x));
                     tmp = rbind(tmp, tmp[1, ]);
                     tmp$X = mytrans_x(tmp$X);
                     tmp$Y = mytrans_y(tmp$Y);
                     tmp
                 })

mynames = sub(".xls$", "", myfiles)
names(mypolys) = mynames

myPolygons = lapply(mynames,
                    function(x) {
                        tmp = mypolys[[x]];
                        Polygons(list(Polygon(cbind(tmp$X, tmp$Y))), x)
                    })

mySpn = SpatialPolygons(myPolygons)
myCNnames = c("嘉纳", "库特丹", "米亚洛", "沃达", "雅达")
myshpdata = SpatialPolygonsDataFrame(mySpn,
                                     data = data.frame(
                                         Names = mynames,
                                         CNnames = myCNnames,
                                         row.names = row.names(mySpn)))

# 我们要注意到：SpatialPolygonsDataFrame类的data成员的字段是可以自定义的，
# 这个是暴露给names函数以及$、[]运算符的。
writePolyShape(x = myshpdata, fn = "data/myDIYmap_poly")
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e77e403796929-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e77e403796929-32">
               32
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-1">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                maptools
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-2">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-3">
               <span class="crayon-v">
                myfiles
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "Jiana.xls"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Kutedan.xls"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Miyaluo.xls"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Woda.xls"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "Yada.xls"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-4">
               <span class="crayon-v">
                mypolys
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                lapply
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myfiles
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                function
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                read
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                table
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                paste0
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "data/"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                rbind
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                mytrans_x
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                Y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                mytrans_y
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                Y
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-i">
                tmp
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-12">
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-13">
               <span class="crayon-v">
                mynames
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                sub
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                ".xls$"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                myfiles
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-14">
               <span class="crayon-e">
                names
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mypolys
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                mynames
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-15">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-16">
               <span class="crayon-v">
                myPolygons
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                lapply
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mynames
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                function
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mypolys
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                Polygons
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                list
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                Polygon
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                cbind
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                X
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                Y
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-21">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-22">
               <span class="crayon-v">
                mySpn
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                SpatialPolygons
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myPolygons
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-23">
               <span class="crayon-v">
                myCNnames
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "嘉纳"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "库特丹"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "米亚洛"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "沃达"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "雅达"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-24">
               <span class="crayon-v">
                myshpdata
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                SpatialPolygonsDataFrame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mySpn
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-25">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-26">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                Names
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mynames
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-27">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                CNnames
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                myCNnames
               </span>
               <span class="crayon-sy">
                ,
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-28">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                row
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                names
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                row
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                names
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mySpn
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-29">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-30">
               <span class="crayon-p">
                # 我们要注意到：SpatialPolygonsDataFrame类的data成员的字段是可以自定义的，
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e77e403796929-31">
               <span class="crayon-p">
                # 这个是暴露给names函数以及$、[]运算符的。
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e77e403796929-32">
               <span class="crayon-e">
                writePolyShape
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                myshpdata
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fn
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "data/myDIYmap_poly"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0222 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        这样我们在就成功保存了shp格式的地图文件（一共生成三个文件，一个shp文件，两个辅助文件）。生成的地图文件可以留给别人用，也可以正常打开绘图了。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e786960090619" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          mydat = readShapePoly("data/myDIYmap_poly.shp")
plot(mydat)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e786960090619-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e786960090619-2">
               2
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e786960090619-1">
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                readShapePoly
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "data/myDIYmap_poly.shp"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e786960090619-2">
               <span class="crayon-e">
                plot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0011 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-17.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-17.png"/>
        </a>
       </p>
       <p style="color: #141412;">
        可以发现，在区域相邻的边界，有咬合分离现象，这是由于我们采样的时候，每个区单独描边，产生了共享边的不一致。不过，我们绘制地图是为了展示流行病学数据，这个误差是可以接受的。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576854bf8e790256886233" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          library(ggplot2)
mysh = fortify(mydat, region = "CNnames")
names(mysh)[1:2] = c("x", "y")
myepidat = data.frame(id = unique(sort(mysh$id)))
myepidat$rand = runif(length(myepidat$id))
tmp = coordinates(mydat)
tmp = as.data.frame(tmp)
tmp$names = mydat$CNnames
ggplot(myepidat) + geom_map(aes(map_id = id, fill = rand), color = "white", map = mysh) +
    geom_text(aes(x = V1,y = V2,label = names), family = "GB1", data = tmp)+
    scale_fill_gradient(high = "red", low = "yellow") +
    expand_limits(mysh) + coord_map()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576854bf8e790256886233-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e790256886233-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e790256886233-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e790256886233-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e790256886233-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e790256886233-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e790256886233-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e790256886233-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e790256886233-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e790256886233-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576854bf8e790256886233-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576854bf8e790256886233-12">
               12
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576854bf8e790256886233-1">
               <span class="crayon-e">
                library
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                ggplot2
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e790256886233-2">
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                fortify
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                region
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "CNnames"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e790256886233-3">
               <span class="crayon-e">
                names
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-cn">
                2
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                c
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "x"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "y"
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e790256886233-4">
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                unique
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                sort
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e790256886233-5">
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                rand
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                runif
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                length
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e790256886233-6">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coordinates
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e790256886233-7">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                as
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                frame
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e790256886233-8">
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-v">
                names
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mydat
               </span>
               <span class="crayon-sy">
                $
               </span>
               <span class="crayon-e">
                CNnames
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e790256886233-9">
               <span class="crayon-e">
                ggplot
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                myepidat
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                geom_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                aes
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                map_id
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                id
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                fill
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                rand
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                color
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "white"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                map
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e790256886233-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                geom_text
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-e">
                aes
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                x
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                V1
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                y
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                V2
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-v">
                label
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                names
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                family
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "GB1"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                data
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                tmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line" id="crayon-576854bf8e790256886233-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                scale_fill_gradient
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                high
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "red"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                low
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "yellow"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576854bf8e790256886233-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                expand_limits
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                mysh
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                coord_map
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0433 seconds] -->
       <p>
       </p>
       <p style="color: #141412;">
        <a href="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-18.png" style="color: #bc360a;">
         <img src="http://dataunion.org/wp-content/uploads/2015/01/unnamed-chunk-18.png"/>
        </a>
       </p>
       <p style="color: #141412;">
        如上，画成统计地图，还算美观。
       </p>
       <p style="color: #141412;">
        如果非要消除这种边界交错的不完美，就需要预先制定规划，在位图上分段采集边界线，再拼接组合成区域轮廓。由于共享边只采集一次，你能得到边界完美的地图。问题是，随着地图区域增多，你将在轮廓的拼接组合上，面临几何级数增长的复杂度。不过，离开现实的功利和胁迫，去追求完美，不也是推动这个世界前进的原动力么？
       </p>
       <h3 style="color: #141412;">
        5 小结
       </h3>
       <p style="color: #141412;">
        尽管我在写作中使用了这个星球上最强大的knitr软件包来保证本文的可重复性，但是随着官方新版数据在未来的发布，数据的字段名称甚至组织布局将会有些变化，也会使本文代码无法直接拷贝运行。还是希望读者能自己掌握R，以无招胜有招。
       </p>
       <p style="color: #141412;">
        喜欢读统计之都主页文章的结尾部分，因为常在此部分读到作者“不着调”的话，发人深省。最爱杨灿兄改编的这段：
       </p>
       <p style="color: #141412;">
        问：世间是否此山最高，或者另有高处比天高？
       </p>
       <p style="color: #141412;">
        答：在世间自有山比此山更高，Open-mind要比天高。
       </p>
       <h3 style="color: #141412;">
        参考文献
       </h3>
       <ol style="color: #141412;">
        <li>
         谢益辉，2007，
         <a href="http://yihui.name/cn/2007/09/china-map-at-province-level/" style="color: #ea9629;">
          http://yihui.name/cn/2007/09/china-map-at-province-level/
         </a>
        </li>
        <li>
         邱怡轩，2009，
         <a href="http://cos.name/2009/07/drawing-china-map-using-r/" style="color: #bc360a;">
          http://cos.name/2009/07/drawing-china-map-using-r/
         </a>
        </li>
        <li>
         陈丽云，2011，
         <a href="http://www.loyhome.com/%E7%94%A8R%E7%94%BB%EF%BC%88%E4%B8%AD%E5%9B%BD%EF%BC%89%E5%9C%B0%E5%9B%BE-2/" style="color: #bc360a;">
          http://www.loyhome.com/用R画（中国）地图-2/
         </a>
        </li>
        <li>
         写长城的诗，2012，
         <a href="http://www.r-bloggers.com/lang/chinese/1010" style="color: #bc360a;">
          http://www.r-bloggers.com/lang/chinese/1010
         </a>
        </li>
        <li>
         杨灿，2011，
         <a href="http://cos.name/2011/12/stories-about-statistical-learning" style="color: #bc360a;">
          http://cos.name/2011/12/stories-about-statistical-learning
         </a>
        </li>
       </ol>
       <p style="color: #141412;">
        附：本文所用地图数据
        <a href="http://cos.name/wp-content/uploads/2014/08/maps_data.7z" style="color: #bc360a;">
         下载
        </a>
       </p>
       <p style="color: #141412;">
        原文链接： http://cos.name/2014/08/r-maps-for-china/
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24678.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/20140917125452915416-216x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24678.html" rel="bookmark" title="python3中的正则模块">
         python3中的正则模块
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24675.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/t015b337bd75d9ef893-161x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24675.html" rel="bookmark" title="注释是恶魔，请不要再写一行注释">
         注释是恶魔，请不要再写一行注释
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24660.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/u16130037972892789947fm21gp0-300x157.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/24660.html" rel="bookmark" title="如何从Github上轻松安装R包">
         如何从Github上轻松安装R包
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/24654.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/06/df53fac99fc53ba5a90666abcca25e6d_b-267x200.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24654.html" rel="bookmark" title="简单形象又有趣地说说强大的神经网络">
         简单形象又有趣地说说强大的神经网络
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F878.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/878.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/878.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>